package com.shuziren.question.entity.dto;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.shuziren.question.entity.InterviewQuestion;
import com.shuziren.question.entity.ProblemsetTopic;
import com.shuziren.question.entity.SortTopic;
import lombok.Data;

import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

import java.util.Date;

@Data
public class InterviewQuestionDTO {
        // interview_question 表的字段
      @TableId(value = "id",type = IdType.AUTO)
      private Integer id;
      // 题目标题
      @NotNull(message = "标题不能为空")
      private String title;
      // 题目描述
      @Size(max = 255, message = "描述长度不能超过255")
      private String description;
      // 题目难度
      @Size(min = 1,max = 3, message = "难度长度必须在1-3之间")
      private Integer difficulty;
      // 题目标签
      @Size(max = 255, message = "标签长度不能超过255")
      private String tags;
      // 题目答题时间
      private Integer expectedTime;
      // 分值(5、10、15)
      @Size(min = 5,max = 15, message = "分值必须在5-15之间")
      private Integer maxScore;
      // 题目答案
      @NotNull(message = "答案不能为空")
      @Size(max = 255, message = "答案长度不能超过255")
      private String answer;
      // 题目状态只有0和1，0表示禁用，1表示启用
      @Min(value = 0, message = "状态必须为0")
      @Max(value = 1, message = "状态必须为1")
      private Integer status;
      // 创建时间
      @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
      private Date createdAt;
      // 更新时间
      @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
      private Date updatedAt;


      // question_category 表的字段
      @TableField("category_id")
      // 分类ID
      private Integer categoryId;
      // 分类名称
      @NotNull(message = "名称不能为空")
      private String categoryName;
      // 分类描述
      @Size(max = 255, message = "描述长度不能超过255")
      private String categoryDescription;
      // 分类状态只有0和1，0表示禁用，1表示启用
      @Min(value = 0, message = "状态必须为0")
      @Max(value = 1, message = "状态必须为1")
      private Integer categoryStatus;


      private Integer questionSetId;

      public InterviewQuestion toInterviewQuestion(){
          InterviewQuestion interviewQuestion = new InterviewQuestion();
          interviewQuestion.setId(this.id);
          interviewQuestion.setTitle(this.title);
          interviewQuestion.setDescription(this.description);
          interviewQuestion.setDifficulty(this.difficulty);
          interviewQuestion.setExpectedTime(this.expectedTime);
          interviewQuestion.setTags(this.tags);
          interviewQuestion.setScore(this.maxScore);
          interviewQuestion.setAnswer(this.answer);
          return interviewQuestion;
      }

      public SortTopic toSort_topic(){
          SortTopic sortTopic = new SortTopic();
          sortTopic.setTopicId(categoryId);

          return sortTopic;
      }

      public ProblemsetTopic tbProblemset_topic(){
          ProblemsetTopic problemsetTopic = new ProblemsetTopic();
          problemsetTopic.setQuestionsetId(questionSetId);
          return problemsetTopic;
      }
}
